package com.zz.cc.business.app;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;

import com.zz.cc.business.R;
import com.zz.common.app.BaseActivity;
import com.zz.common.widget.ZListView;

public class MainActivity extends BaseActivity implements OnClickListener, OnItemClickListener {
	
	private EditText mInputPublish;
	
	private ZListView mListView;
	private PublishAdapter mAdapter;
	
	private Button mReserve;
	private Button mService;
	private Button mOther;
	private Button mQrCode;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		initUI();
		fillView();
	}
	
	private void initUI() {
		mInputPublish = (EditText) findViewById(R.id.main_publish_info);
		
		mListView = (ZListView) findViewById(R.id.main_info_list);
		
		View buttonGroup = findViewById(R.id.main_button_group);
		mReserve = (Button) buttonGroup.findViewById(R.id.main_button_reserve);
		mService = (Button) buttonGroup.findViewById(R.id.main_button_service);
		mOther = (Button) buttonGroup.findViewById(R.id.main_button_other);
		mQrCode = (Button) buttonGroup.findViewById(R.id.main_button_qrcode);
	}
	
	private void fillView() {
		mAdapter = new PublishAdapter();
		mListView.setAdapter(mAdapter);
		mListView.setOnItemClickListener(this);
		
		mReserve.setOnClickListener(this);
		mService.setOnClickListener(this);
		mOther.setOnClickListener(this);
		mQrCode.setOnClickListener(this);
	}
	
	private void gotoReserveListActivity() {
		Intent intent = new Intent(this, ReserveListActivity.class);
		startActivity(intent);
		overridePendingTransition(R.anim.activity_slide_right_in, R.anim.activity_slide_left_out);
	}
	
	private void gotoServiceListActivity() {
		Intent intent = new Intent(this, ServiceListActivity.class);
		startActivity(intent);
		overridePendingTransition(R.anim.activity_slide_right_in, R.anim.activity_slide_left_out);
	}
	
	private void gotoOtherActivity() {
		Intent intent = new Intent(this, OtherActivity.class);
		startActivity(intent);
		overridePendingTransition(R.anim.activity_slide_right_in, R.anim.activity_slide_left_out);
	}
	
	private void gotoQrCodeActivity() {
		Intent intent = new Intent(this, QrCodeActivity.class);
		intent.putExtra(QrCodeActivity.INDEX_QR_CODE, "http://www.google.com.tw");
		startActivity(intent);
		overridePendingTransition(R.anim.activity_slide_right_in, R.anim.activity_slide_left_out);
	}
	
	@Override	//View.OnClickListener
	public void onClick(View v) {
		switch(v.getId()) {
		case R.id.main_button_reserve:
			gotoReserveListActivity();
			break;
		
		case R.id.main_button_service:
			gotoServiceListActivity();
			break;
		
		case R.id.main_button_other:
			gotoOtherActivity();
			break;
			
		case R.id.main_button_qrcode:
			gotoQrCodeActivity();
			break;
			
		default:
			break;
		}
	}
	
	@Override	//AdapterView.OnItemClickListener
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		
	}
	
	private class PublishAdapter extends BaseAdapter {

		@Override
		public int getCount() {
			// TODO
			return 0;
		}

		@Override
		public Object getItem(int position) {
			// TODO
			return null;
		}

		@Override
		public long getItemId(int position) {
			// TODO
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			//TODO
			return null;
		}
		
	}

}
